/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

// used in add subject jsp
function getStream(id, value) {
    var a = "<option value=''>Select Stream</option>";
    var xmlhttp;
    if (window.XMLHttpRequest)
    {
        xmlhttp = new XMLHttpRequest();
    }
    else
    {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange = function()
    {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
        {
            document.getElementById(id).innerHTML = a + xmlhttp.responseText;
        }
    }
    xmlhttp.open("POST", "/RIT/GetStream?course=" + value, true);
    xmlhttp.send();
}

// used in Add Subject jsp
function getCoursePeriod(val, trg) {
    var a = "<option value=''>Select Semester/Year</option>";
    var xmlhttp;
    if (window.XMLHttpRequest)
    {
        xmlhttp = new XMLHttpRequest();
    }
    else
    {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange = function()
    {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
        {
            document.getElementById(trg).innerHTML = a + xmlhttp.responseText;
        }
    }
    xmlhttp.open("POST", "/RIT/GetCoursePeriod?course=" + val, true);
    xmlhttp.send();
}

//used in Fees jsp
function getStream1(id, value) {
    var a = "<option value=''>Select Stream</option><option value='0'>All</option>";
    var xmlhttp;
    if (window.XMLHttpRequest)
    {
        xmlhttp = new XMLHttpRequest();
    }
    else
    {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange = function()
    {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
        {
            document.getElementById(id).innerHTML = a + xmlhttp.responseText;
        }
    }
    xmlhttp.open("POST", "/RIT/GetStream?course=" + value, true);
    xmlhttp.send();
}

// used in Fees jsp
function getCoursePeriod1(val, trg) {
    var a = "<option value=''>Select Year/Semester</option><option value='0'>All</option>";
    var xmlhttp;
    if (window.XMLHttpRequest)
    {
        xmlhttp = new XMLHttpRequest();
    }
    else
    {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange = function()
    {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
        {

            document.getElementById(trg).innerHTML = a + xmlhttp.responseText;
        }
    }
    xmlhttp.open("POST", "/RIT/GetCoursePeriod?course=" + val, true);
    xmlhttp.send();
}

function getState(value, trg) {

    var a = "<option value=''>Select State</option>";
    var xmlhttp;
    if (window.XMLHttpRequest)
    {
        xmlhttp = new XMLHttpRequest();
    }
    else
    {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange = function()
    {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
        {
            document.getElementById(trg).innerHTML = a + xmlhttp.responseText;
        }
    }
    xmlhttp.open("POST", "/RIT/GetState?country=" + value, true);
    xmlhttp.send();
}

function setPhoto(src, trg) {


    var oFReader = new FileReader();
    oFReader.readAsDataURL(document.getElementById(src).files[0]);

    oFReader.onload = function(oFREvent) {
        document.getElementById(trg).src = oFREvent.target.result;
        document.getElementById('photo1').href = oFREvent.target.result;
    };
}
;

function getServerImage()
{
    var name = document.getElementById('photo').title;
    var xmlhttp;
    if (window.XMLHttpRequest)
    {
        xmlhttp = new XMLHttpRequest();
    }
    else
    {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange = function()
    {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
        {
            document.getElementById("photo").src = xmlhttp.responseText;
            $("[value|='***']").val('');
            $("[value|='null']").val('');
        }
    }
    xmlhttp.open("POST", "/RIT/GetFileServlet?name=" + name, true);
    xmlhttp.send();
}

function getSemester(course, stream) {
    course = document.getElementById('course').value;

    var xmlhttp;
    if (window.XMLHttpRequest)
    {
        xmlhttp = new XMLHttpRequest();
    }
    else
    {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange = function()
    {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
        {
            document.getElementById('semester').innerHTML = xmlhttp.responseText;
        }
    }
    xmlhttp.open("POST", "/RIT/GetSemester?course=" + course + "&stream=" + stream, true);
    xmlhttp.send();
}
function getSubject(stream, sem) {

    var xmlhttp;
    if (window.XMLHttpRequest)
    {
        xmlhttp = new XMLHttpRequest();
    }
    else
    {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange = function()
    {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
        {
            document.getElementById('subject').innerHTML = xmlhttp.responseText;
        }
    }
    xmlhttp.open("POST", "/RIT/GetSubject?stream=" + stream + "&sem=" + sem, true);
    xmlhttp.send();
}
function getStuList(courseid, sem, sub) {
    var xmlhttp;
    if (window.XMLHttpRequest)
    {
        xmlhttp = new XMLHttpRequest();
    }
    else
    {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange = function()
    {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
        {
            document.getElementById('tbody').innerHTML = xmlhttp.responseText;
        }
    }
    xmlhttp.open("POST", "/RIT/GetStuList?courseid=" + courseid + "&sem=" + sem + "&subid=" + sub, true);
    xmlhttp.send();
}


